local gongxin = fk.CreateSkill {
  name = "mini__gongxin",
}

Fk:loadTranslationTable{
  ["mini__gongxin"] = "攻心",
  [":mini__gongxin"] = "出牌阶段限一次，你可以观看一名其他角色的手牌，然后你可以展示其中一张红色牌，"..
  "选择一项：1.获得此牌；2.将此牌置于牌堆顶。",

  ["#mini__gongxin"] = "攻心：观看一名角色的手牌，获得其中一张红色牌或置于牌堆顶",
  ["mini__gongxin_prey"] = "获得此牌",

  ["$mini__gongxin1"] = "心战胜，则无往不胜。",
  ["$mini__gongxin2"] = "君无顺民，将无忠士，汝将以何为战？",
}

gongxin:addEffect("active", {
  anim_type = "control",
  prompt = "#mini__gongxin",
  target_num = 1,
  card_num = 0,
  can_use = function(self, player)
    return player:usedSkillTimes(gongxin.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select ~= player and not to_select:isKongcheng()
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local cards = target:getCardIds("h")
    local hearts = table.filter(cards, function (id)
      return Fk:getCardById(id).color == Card.Red
    end)
    local ids, choice = room:askToChooseCardsAndChoice(player, {
      cards = hearts,
      choices = { "mini__gongxin_prey", "gongxin_put" },
      skill_name = gongxin.name,
      prompt = "#gongxin-view::" .. target.id,
      cancel_choices = { "Cancel" },
      min_num = 1,
      max_num = 1,
      all_cards = cards
    })
    if choice == "mini__gongxin_prey" then
      room:moveCardTo(ids, Card.PlayerHand, player, fk.ReasonPrey, gongxin.name, nil, false, player)
    elseif choice == "gongxin_put" then
      room:moveCardTo(ids, Card.DrawPile, nil, fk.ReasonPut, gongxin.name, nil, true)
    end
  end,
})

return gongxin
